#include"card.h"
#include"game_window.h"
#include<QtGui>

GameWindow::GameWindow(QWidget* pwgt) : QWidget(pwgt), napravleniey(true)
{
	point=QPointF(50.0,50.0);
	startTimer(100);
//	startTimer(100);
//	startTimer(150);
	qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
//	qDebug() << this;
}

void GameWindow::paintEvent(QPaintEvent*)
{
	QPainter	paint(this);
	paint.setRenderHint(QPainter::Antialiasing, true);
	QColor	color;
	color.setRgb(0,0,0);
	paint.setPen(QPen(color, 30.0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
	paint.drawPoint(point);
//	qDebug() << this;
	QPixmap	pix("cards-aisleriot/33.png");
	paint.drawPixmap(point, pix);
	qDebug() << pix.size();
}

void GameWindow::timerEvent(QTimerEvent *event)
{
	if (point.ry() >= (size()).rheight()-10)
		napravleniey=false;
	if (point.ry() <= 10)
		napravleniey=true;
	if (napravleniey)
		point.ry()+=3;
	else
		point.ry()-=3;
	
	if (point.rx() >= (size()).rwidth()-10)
		napravleniex=false;
	if (point.rx() <= 10)
		napravleniex=true;
	if (napravleniex)
		point.rx()+=3;
	else
		point.rx()-=3;
//	qDebug() << "Timer ID:" << event->timerId();
	update();
}

